#include"Daudio.h"
CSoundManager *dsound;

int Init_DirectSound(HWND hwnd)
{
    HRESULT result;
    dsound = new CSoundManager();
    result = dsound->Initialize(hwnd, DSSCL_PRIORITY);
    if (result != DS_OK)
        return 0;
    result = dsound->SetPrimaryBufferFormat(2, 22050, 16);
    if (result != DS_OK)
        return 0;
    return 1;
}

CSound *LoadSound(LPWSTR filename)
{
    HRESULT result;
	CSound *wave;
	result = dsound->Create(&wave, filename);
    if (result != DS_OK)
        return NULL;
    return wave;
}

void PlaySound(CSound *sound)
{
    sound->Play();
}
void ReSet(CSound *sound)
{
	sound->Reset();
}
void LoopSound(CSound *sound)
{
    sound->Play(0, DSBPLAY_LOOPING);
}

void StopSound(CSound *sound)
{
    sound->Stop();
}
